package com.cnswhy.cloud.server.merchant.controller.spell;

import com.cnswhy.cloud.server.core.entity.SpellInfo;
import com.cnswhy.cloud.server.core.dto.SpellInfoSaveDTO;
import com.cnswhy.cloud.server.core.dto.SpellInfoUpdateDTO;
import com.cnswhy.cloud.server.core.dto.SpellInfoPageDTO;
import com.cnswhy.cloud.server.core.service.SpellInfoService;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.cnswhy.cloud.common.core.base.controller.SuperController;
import com.cnswhy.cloud.common.core.base.R;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
//import com.github.zuihou.security.annotation.PreAuth;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 前端控制器
 * 
 * </p>
 *
 * @author cnswhy
 * @date 2020-10-16
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/spellInfo")
@Api(value = "SpellInfo", tags = "")
//@PreAuth(replace = "spellInfo:")
public class SpellInfoController extends SuperController<SpellInfoService, Long, SpellInfo, SpellInfoPageDTO, SpellInfoSaveDTO, SpellInfoUpdateDTO> {

    /**
     * Excel导入后的操作
     *
     * @param list
     */
    @Override
    public R<Boolean> handlerImport(List<Map<String, String>> list){
        List<SpellInfo> spellInfoList = list.stream().map((map) -> {
            SpellInfo spellInfo = SpellInfo.builder().build();
            return spellInfo;
        }).collect(Collectors.toList());

        return R.success(baseService.saveBatch(spellInfoList));
    }
}
